{include "Public/header"}
<div class="container-fluid">
  <div class="row-fluid">
    <div class="span12">
      <div class="widget-box">
        <div class="widget-title"> <span class="icon"> <i class="icon-align-justify"></i> </span>
          <h5>{$title}</h5>
        </div>
        <div class="widget-content nopadding">
          <form action="{:U('updatePwd')}" method="post" class="form-horizontal">
            <div class="control-group">
              <label class="control-label">Old password:</label>
              <div class="controls">
                <input type="password" maxlength="32" name="old_password" class="span11" placeholder="Please enter the old password" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">New password:</label>
              <div class="controls">
                <input type="password" maxlength="32" name="password" id="password" class="span11" placeholder="Please enter a new password" />
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Repeat password:</label>
              <div class="controls">
                <input type="password" maxlength="32" name="repassword" class="span11" placeholder="Please enter your password again" />
              </div>
            </div>
            <div class="form-actions">
              <input type="submit" class="btn btn-success" value="save">
              <input type="reset" id="reset" style="display:none;" />
              <span class="help-inline" style="color:red;" id="msg"></span>
            </div>
          </form>
        </div>
      </div>
     </div>
</div></div>
{include "Public/footer"}
<script>
$(function(){
	$("form").validate({
		rules:{
			old_password:{
				required:true
			},
			password:{
				required:true,
				minlength:6
			},
			repassword:{
				required:true,
				equalTo:"#password"
			}
		},
		messages:{
			old_password:{
				required:"required"
			},
			password:{
				required:"required",
				minlength:"More than 6 bits"
			},
			repassword:{
				required:"required",
				equalTo:"Inconsistent password"
			}
		}
		,
		submitHandler: function(form) {
			$.post("{:U('updatePwd')}",$(form).serialize(),function(rs){
				if(rs.status==1){
					$("#msg").html('Change password success').show();
					$("#reset").click();
				}else{
					$("#msg").html(rs.msg).show();
				}
			},'json');
		    return false;
		}
	});
	$("input[name='old_password'],input[name='password'],input[name='repassword']").keydown(function(){
		$("#msg").hide();
	});
});
</script>